import $request from '../request.js'

/**
 * 项目分类
 */
export const getProjectCategory = () => {
	return $request({
		method: 'get',
		url: '/api/app/project/category',
	})
}

/**
 * 项目列表
 * page integer
 * page_size integer
 * search_text string
 */
export const getProjectList = (data) => {
	return $request({
		method: 'post',
		url: '/api/app/project/list',
		data
	})
}

/**
 * 项目详情
 */
// export const getProjectDetail = (data) => {
// 	return $request({
// 		method: 'get',
// 		url: `/api/app/project/${data.id}`,
// 	})
// }
export const getProjectDetail = (data) => {
	return $request({
		method: 'post',
		url: `/api/app/project/detail`,
		data
	})
}
/**
 * Banner图
 */
export const getBannerList = (data) => {
	return $request({
		method: 'get',
		url: `/api/app/project/index`,
	})
}


/**
 * 领取题目
 * project_id string
 * topic_number integer
 */
export const getTopic = (data) => {
	return $request({
		method: 'post',
		url: `/api/app/project/get_topic`,
		data
	})
}

/**
 * 放弃题目
 * id integer 
 * reason string
 */
export const giveUpTopic = (data) => {
	return $request({
		method: 'post',
		url: `/api/app/topic/give_up`,
		data
	})
}

/**
 * 返修题目列表
 * project_id
 */
export const getRepairList = (data) => {
	return $request({
		method: 'post',
		url: `/api/app/topic/repair/list`,
		data
	})
}

/**
 * 提交记录
 * page integer
 * page_size integer
 * project_id string
 */
export const getSubmitRecord = (data) => {
	return $request({
		method: 'post',
		url: `/api/app/topic/submit_record/list`,
		data
	})
}

/**
 * 获取角标
 */
export const getBadge = (data) => {
	return $request({
		method: 'get',
		url: `/api/app/project/badge/${data.id}`,
	})
}
/**
 * 获取角标
 */
export const updateProjectMsgStatus = (data) => {
	return $request({
		method: 'post',
		url: `/api/app/project/update_project_msg_status`,
		data
	})
}

/**
 * 项目任务消息
 * page integer
 * page_size integer
 * project_id string
 */
export const getMessageList = (data) => {
	return $request({
		method: 'post',
		url: `/api/app/project/message/list`,
		data
	})
}

/**
* 提交答案
* answerarray[object]
* {
*	 answer_size integer
*	 content string 答题答案
*	 id integer 配置Id
*	 tp integer 答题类型 0 文本 1 文件
* }
* project_id string
* system_topic_id integer
* topic_id
*/
export const submitAnswer = (data) => {
	return $request({
		method: 'post',
		url: `/api/app/topic/submit_answer`,
		data
	})
}

/**
 * 获取STSToken
 */
export const getSTSToken = () => {
	return $request({
		method: 'post',
		url: `/api/app/oss/sts`,
	})
}